using Godot;
using System;

public class Button : Godot.Button
{
    AnimationPlayer ap;
    public delegate void ButtonDown(Button button);

    public ButtonDown ButtonDownEvent;

    Label label;

    public override void _Ready()
    {
        label = GetNode<Label>("Label");
        ap = GetNode<AnimationPlayer>("AnimationPlayer");
        label.RectPivotOffset = this.RectSize/2;
    }

    public void button_down()
    {
        if (ButtonDownEvent != null)
            ButtonDownEvent(this);
    }
    public string GetTitle()
    {
        return label.Text;
    }
    public Button SetTitle(String title, bool bbcode = false)
    {
        if (label == null) return this;

        if (bbcode)
        {

        }
        else
        {
            label.Text = title;
        }
        return this;
    }
    public Button SetEvent(ButtonDown e)
    {
        ButtonDownEvent = e;
        return this;
    }
    
    public void HoverIn()
    {
        ap.Play("hover");
    }
    public void HoverOut()
    {
        ap.Play("over");
    }
}
